function requestImg(){
    var p = new Promise(function(resolve,reject){
        var img = new Image();
        img.onload = function (){
            resolve(img);
        }
        img.src = 'http://img1.gtimg.com/sports/pics/hv1/150/118/2217/144190665.png';
    })
    return p;
}

function timeout(){
    var p = new Promise(function(resolve,reject){
        setTimeout(function(){
            reject('图片请求超时')
        },5000)
    })
    return p;
}

Promise.race([requestImg(),timeout()])
.then(function(data){
    console.log(data)
})